package com.citasgoo.aliyunFacility.api;

import com.citasgoo.aliyunFacility.util.Base64JDK;
import com.citasgoo.aliyunFacility.util.StringUtil;

public class AliyunKey {

    private static String ACCESS_KEY_ID = "";

    private static String ACCESS_SECRET = "";

    private static String SIGN_NAME = "CitAs";

    private static String BUCKET_NAME = "citas-test";

    private static String OSS_HOST = "https://citas-test.oss-cn-shenzhen.aliyuncs.com/";

    private static String FROM_ACCOUNT = "support@mail.citasgoo.cn";

    private static String FROM_ALIAS = "应用支持组";

    private static String TAG_NAME = "support";

    public static String getAccessKeyId() {
        return ACCESS_KEY_ID;
    }

    public static String getAccessSecret() {
        return ACCESS_SECRET;
    }

    public static String getSignName() {
        return SIGN_NAME;
    }

    public static String getBucketName() {
        return BUCKET_NAME;
    }

    public static String getOssHost() {
        return OSS_HOST;
    }

    public static String getFromAccount() {
        return FROM_ACCOUNT;
    }

    public static String getFromAlias() {
        return FROM_ALIAS;
    }

    public static String getTagName() {
        return TAG_NAME;
    }

    static {
//        System.out.println("ACCESS_KEY_ID："+System.getenv("ACCESS_KEY_ID"));
//        System.out.println("ACCESS_SECRET："+System.getenv("ACCESS_SECRET"));
        if (StringUtil.isBlank(System.getenv("ACCESS_KEY_ID")) || StringUtil.isBlank(System.getenv("ACCESS_SECRET"))) {

        } else {

            ACCESS_KEY_ID = Base64JDK.decode(System.getenv("ACCESS_KEY_ID"));
            ACCESS_SECRET = Base64JDK.decode(System.getenv("ACCESS_SECRET"));
        }
        if (StringUtil.isNotBlank(System.getenv("SIGN_NAME"))) {
            SIGN_NAME = System.getenv("SIGN_NAME");
        }
        if (StringUtil.isNotBlank(System.getenv("BUCKET_NAME"))) {
            BUCKET_NAME = System.getenv("BUCKET_NAME");
        }
        if (StringUtil.isNotBlank(System.getenv("OSS_HOST"))) {
            BUCKET_NAME = System.getenv("OSS_HOST");
        }
        if (StringUtil.isNotBlank(System.getenv("FROM_ACCOUNT"))) {
            FROM_ACCOUNT = System.getenv("FROM_ACCOUNT");
        }
        if (StringUtil.isNotBlank(System.getenv("FROM_ALIAS"))) {
            FROM_ALIAS = System.getenv("FROM_ALIAS");
        }
        if (StringUtil.isNotBlank(System.getenv("TAG_NAME"))) {
            TAG_NAME = System.getenv("TAG_NAME");
        }
        System.out.println("init finished");
        System.out.println("ACCESS_KEY_ID"+Base64JDK.encode(ACCESS_KEY_ID));

    }



}

